package com.starbaba.loanorder.service.impl;

import java.util.List;
import java.util.Map;

import com.base.common.log.LogService;
import org.apache.commons.lang3.StringUtils;

import com.base.common.database.BaseDao;
import com.base.common.exception.AppException;
import com.starbaba.core.web.page.PageResponse;
import com.starbaba.loanorder.model.LoanOrderModel;
import com.starbaba.loanorder.model.LoanOrderRequestModel;
import com.starbaba.loanorder.service.LoanOrderService;
import com.starbaba.model.dictionary.Constant;
import com.tuanzi.server.loan_base.model.db.apiModel.Loan_Request_Api_Model_Log;
import com.tuanzi.server.loan_base.util.PhoneNumNideUtil;

@SuppressWarnings("rawtypes")
public class LoanOrderServiceImpl implements LoanOrderService{
	
	@SuppressWarnings("deprecation")
    private static BaseDao dao = new BaseDao(Constant.POOL_LIFE);
	
	public static void main(String[] args) {
		String s = "13415809906";
		String ss = s.substring(0, 3)+"****"+s.substring(7, 11);
		System.out.println(ss);
	}
    
	@Override
	public List<LoanOrderModel> getDataList(int iDisplayStart, int iDisplayLength, 
			PageResponse pageResponse, Map<String, Object> paramsMap) {
		
		String platform = (String) paramsMap.get("platform");
		String prdId = (String) paramsMap.get("prdid");
		String channel = (String) paramsMap.get("channel");
		String orderId = (String) paramsMap.get("orderId");
		String typeId = (String) paramsMap.get("type");
		String mobnum = (String) paramsMap.get("mobnum");
		String status = (String) paramsMap.get("status");
		String startTime = (String) paramsMap.get("startTime");
		String endTime = (String) paramsMap.get("endTime");
		String tranStartTime = (String) paramsMap.get("tranStartTime");
		String tranEndTime = (String) paramsMap.get("tranEndTime");  
		String orderType = (String) paramsMap.get("orderType"); 
		String environment = (String) paramsMap.get("environment");
		String requestSource = (String) paramsMap.get("request_source");

		StringBuffer sql = new StringBuffer();
		sql.append("select a.id, a.userid,a.mobnum,a.petname, b.idcard, b.petname,b.profession, a.request_source,");
		sql.append("b.province, b.identy, b.city, b.adress, a.amount,a.type,a.status,a.peroid,a.loan_amount,a.loan_time,");
		sql.append("a.settle_amount, a.authorize, a.auth_time, a.ctime,a.transaction_time, b.platform, b.product_id, a1.name product_name,");
		sql.append("b.channel, c.channel_name,a.order_type,a.environment from loan_order a LEFT JOIN loan_user_info b on (a.userid = b.userid) ");
		sql.append("left join comm_product_channel c on (c.channel_code = b.channel) ");
		sql.append("left join comm_product_prdid a1 on (a1.prdid = b.product_id) where 1=1 ");

		String selectSql = "";
		if (StringUtils.isNotEmpty(orderId)) {
			selectSql += " and a.id = " + orderId;
		}
		if (StringUtils.isNotEmpty(typeId)) {
			selectSql += " and a.type = " + typeId;
		}
		if (StringUtils.isNotEmpty(mobnum)) {
			selectSql += " and a.mobnum = '" + mobnum + "'";
		}
		if (StringUtils.isNotEmpty(status)) {
			selectSql += " and a.status = " + status;
		}
		if (StringUtils.isNotEmpty(startTime)) {
			selectSql += " and a.ctime >= '" + startTime + " 00:00:00'";
		}
		if (StringUtils.isNotEmpty(endTime)) {
			selectSql += " and a.ctime <= '" + endTime + " 23:59:59'";
		}
		if (StringUtils.isNotEmpty(tranStartTime)) {
			selectSql += " and a.transaction_time >= '" + tranStartTime + " 00:00:00'";
		}
		if (StringUtils.isNotEmpty(tranEndTime)) {
			selectSql += " and a.transaction_time <= '" + tranEndTime + " 23:59:59'";
		}
		if (StringUtils.isNotEmpty(platform)) {
			selectSql += " and b.platform = '" + platform + "'";
		}
		if (StringUtils.isNotEmpty(channel)) {
			selectSql += " and b.channel = " + channel;
		}
		if (StringUtils.isNotEmpty(prdId)) {
			selectSql += " and b.product_id = '" + prdId + "'";
		}
		if (StringUtils.isNotEmpty(orderType)) {
			selectSql += " and a.order_type = " + orderType + "";
		}  
		if (StringUtils.isNotEmpty(environment)) {
			selectSql += " and a.environment = " + environment + "";
		}
		if (StringUtils.isNotEmpty(requestSource)) {
			selectSql += " and a.request_source = " + requestSource + "";
		}

		sql.append(selectSql);
		sql.append(" order by a.ctime desc ");

		if (sql.length() > 0 && iDisplayStart >= 0 && iDisplayLength > 0) {
			sql.append(" limit " + iDisplayStart + " , " + iDisplayLength);
		}

		String countSql = "select count(1) from loan_order a "
				+ " LEFT JOIN loan_user_info b on (a.userid = b.userid) where 1=1 " + selectSql;
		List<LoanOrderModel> list = null;
		try {
			int count = dao.getInt(countSql);
			list = dao.list(sql.toString(), LoanOrderModel.class, new Object[] {});
			if(list != null) {
				for(LoanOrderModel model : list) {
					model.setMobnum(PhoneNumNideUtil.hideNum(model.getMobnum()));
					model.setIdcard(PhoneNumNideUtil.hideIdCard(model.getIdcard()));
					model.setPetname(PhoneNumNideUtil.hideName(model.getPetname()));
				}
			}
			pageResponse.setITotalRecords(count);
			pageResponse.setITotalDisplayRecords(count);
		} catch (AppException e) {
			e.printStackTrace();
		}
		return list;
	}

	@Override
	public String exportLoanOrderList(List<LoanOrderModel> list) {
		
		StringBuffer sf = new StringBuffer();
		sf.append("订单编号,合作方,手机号码,申请借款金额,实际放款金额,实际放款时间,提交申请时间,审核时间,订单状态,真实姓名,身份证号,职业身份,省份,地区,县（区）,详细地址,平台,产品,渠道,订单类型,请求环境,请求来源\r\n");

		for (LoanOrderModel vo : list) {
			sf.append("'" + vo.getId()).append(",");
			Integer type = vo.getType();
			if (type != null) {
				switch (type) {
				case 1:
					sf.append("捷信福贷").append(",");
					break;
				default:
					sf.append("--").append(",");
					break;
				}
			} else {
				sf.append("--").append(",");
			}
			sf.append(vo.getMobnum()).append(",");
			sf.append("'" + vo.getAmount()).append(",");
			if (vo.getLoan_amount() == null) {
				sf.append("--").append(",");
			} else {
				sf.append("'" + vo.getLoan_amount()).append(",");
			}
			if (vo.getLoan_time() == null) {
				sf.append("--").append(",");
			} else {
				sf.append("'" + vo.getLoan_time()).append(",");
			}
			sf.append("'" + vo.getCtime()).append(",");
			if (vo.getTransaction_time() == null) {
				sf.append("--").append(",");
			} else {
				sf.append("'" + vo.getTransaction_time()).append(",");
			}
			
			Integer status = vo.getStatus();
			if (status != null) {
				switch (status) {
				case 2:
					sf.append("账号校验失败").append(",");
					break;
				case 3:
					sf.append("审核中").append(",");
					break;
				case 4:
					sf.append("合作方取消").append(",");
					break;
				case 5:
					sf.append("初审成功").append(",");
					break;
				case 6:
					sf.append("申请成功").append(",");
					break;
				case 7:
					sf.append("合作方退回").append(",");
					break;
				default:
					sf.append("--").append(",");
					break;
				}
			} else {
				sf.append("--").append(",");
			}
			sf.append(vo.getPetname()).append(",");
			sf.append("'" + vo.getIdcard()).append(",");
			sf.append(vo.getProfession()).append(",");
			sf.append(vo.getProvince()).append(",");
			sf.append(vo.getIdenty()).append(",");
			sf.append(vo.getCity()).append(",");
			sf.append(vo.getAdress()).append(",");
			sf.append(vo.getPlatform()).append(",");
			sf.append(vo.getProduct_name()).append(",");
			sf.append(vo.getChannel_name()).append(",");
			
			if(vo.getOrder_type() == null) {
				sf.append("未知").append(",");
			}else if(vo.getOrder_type() == 1){
				sf.append("单独API投递").append(",");
			}else if(vo.getOrder_type() == 2){
				sf.append("一键API投递").append(",");
			}else{
				sf.append("未知").append(",");
			}
			
			if("1".equals(vo.getEnvironment())){
				sf.append("H5").append(",");
			}else if("2".equals(vo.getEnvironment())){
				sf.append("站内").append(",");
			}else{
				sf.append("未知").append(",");
			}
			
			if("1".equals(vo.getRequest_source())){
				sf.append("菠萝贷").append(",");
			}else if("2".equals(vo.getRequest_source())){
				sf.append("银河黑卡").append(",");
			}else{
				sf.append("未知").append(",");
			}
			
			sf.append("\r\n");
		}
		return sf.toString();
	}

	@Override
	public List<LoanOrderRequestModel> getRequestList(int iDisplayStart, int iDisplayLength, PageResponse pageResponse, Map<String, Object> paramsMap) {
		
		String type = (String)paramsMap.get("type");
		String orderId = (String)paramsMap.get("order_id");
		
		try {
			List<LoanOrderRequestModel> list = dao.list("select order_id, request_json, response_json, url, type "
					+ " from loan_api_request_info where order_id = ? and type = ? order by createtime desc", LoanOrderRequestModel.class, orderId, type);
			return list;
		} catch (AppException e) {
			e.printStackTrace();
		}
		return null;
	}
	
	
	@Override
	public List<LoanOrderModel> getStatDataList(int iDisplayStart, int iDisplayLength, 
			PageResponse pageResponse, Map<String, Object> paramsMap) {
		
		String platform = (String) paramsMap.get("platform");
		String prdId = (String) paramsMap.get("prdid");
		String channel = (String) paramsMap.get("channel");
		String new_activity_Id = (String) paramsMap.get("new_activity_id");
		String new_activity_type = (String) paramsMap.get("new_activity_type");
		String environment = (String) paramsMap.get("environment");
		String page = (String) paramsMap.get("page");
		String ck_module = (String) paramsMap.get("ck_module");
		String position = (String) paramsMap.get("position");
		String user_type = (String) paramsMap.get("user_type");
		String api_type = (String) paramsMap.get("api_type");
		String order_type = (String) paramsMap.get("order_type");
		String startDate = (String) paramsMap.get("startDate");
		String endDate = (String) paramsMap.get("endDate");
		String status = (String) paramsMap.get("status");
		String isChannel = (String) paramsMap.get("is_channel");
		String request_source = (String) paramsMap.get("request_source");
		
		boolean isChannelResult = true;
		
		if (StringUtils.isNotEmpty(isChannel) && "2".equals(isChannel)) {
			isChannelResult = false; 
		}
	    
		// 查询提交API人数
		StringBuffer sql = new StringBuffer();
		sql.append("select date(a.ctime) date, a.channel, b.channel_name, c.name product_name, ");
		sql.append("a1.third_name third_name,a.platform,a.new_activity_type, a.new_activity_id, a.environment, ");
		sql.append("a.user_type, a.page,a.ck_module,a.position,a.type,a.request_source, count(distinct a.mobnum) submit_count ");
		sql.append("from loan_order a left join comm_product_channel b on (a.channel = b.channel_code) ");
		sql.append("left join comm_product_prdid c on (c.prdid = a.product_id) ");
		sql.append("left join loan_api_third a1 on (a1.third_id = a.type) ");
		sql.append("where 1=1 ");
		
		String selectSql = "";
		
		if (StringUtils.isNotEmpty(platform)) {
			selectSql += " and a.platform = '" + platform + "'";
		}
		if (StringUtils.isNotEmpty(channel)) {
			selectSql += " and a.channel = " + channel;
		}
		if (StringUtils.isNotEmpty(environment)) {
			selectSql += " and a.environment = '" + environment + "'";
		}
		if (StringUtils.isNotEmpty(page)) {
			selectSql += " and a.page = '" + page + "'";
		}
		if (StringUtils.isNotEmpty(ck_module)) {
			selectSql += " and a.ck_module = '" + ck_module + "'";
		}
		if (StringUtils.isNotEmpty(position)) {
			selectSql += " and a.position = '" + position + "'";
		}
		if (StringUtils.isNotEmpty(user_type)) {
			selectSql += " and a.user_type = " + user_type;
		}
		if (StringUtils.isNotEmpty(order_type)) {
			selectSql += " and a.order_type = " + order_type;
		}
		if (StringUtils.isNotEmpty(request_source)) {
			selectSql += " and a.request_source = " + request_source;
		}
		
		sql.append(selectSql);
		
		StringBuffer recordSql = new StringBuffer();

		if (StringUtils.isNotEmpty(api_type)) {
			recordSql.append(" and a.type = " + api_type);
		}
		if (StringUtils.isNotEmpty(prdId)) {
			recordSql.append(" and a.product_id = '" + prdId + "'");
		}
		if (StringUtils.isNotEmpty(new_activity_type)) {
			recordSql.append(" and a.new_activity_type = '" + new_activity_type + "'");
		}
		if (StringUtils.isNotEmpty(new_activity_Id)) {
			recordSql.append(" and a.new_activity_id = '" + new_activity_Id + "'");
		}
		if (StringUtils.isNotEmpty(status)) {
			recordSql.append(" and a.status = " + status);
		}
		if (StringUtils.isNotEmpty(startDate)) {
			recordSql.append(" and a.ctime >= '" + startDate + " 00:00:00'");
		}
		if (StringUtils.isNotEmpty(endDate)) {
			recordSql.append(" and a.ctime <= '" + endDate + " 23:59:59'");
		}
		
		sql.append(recordSql);
		
		if (!isChannelResult) {
			sql.append(" group by date ");
		} else {
			// 按渠道分组
			sql.append(" group by date, a.channel ");
		}
		sql.append(" order by date desc ");

		if (sql.length() > 0 && iDisplayStart >= 0 && iDisplayLength > 0) {
			sql.append(" limit " + iDisplayStart + " , " + iDisplayLength);
		}

		LogService.info("apiSql= " + sql.toString());
		
		// 查询每天API投递甲方数
		StringBuffer sourceSql = null;
		
		if (!isChannelResult) {
			sourceSql = new StringBuffer();
			sourceSql.append("select date(a.ctime) date, ");
			sourceSql.append("count(distinct a.userid, a.type) submit_source_count ");
			sourceSql.append("from loan_order a where 1=1 ");
			sourceSql.append(selectSql);
			sourceSql.append(recordSql);
			sourceSql.append(" group by date order by date desc ");
		} else {
			sourceSql = new StringBuffer();
			sourceSql.append("select date(a.ctime) date, a.channel,b.channel_name, ");
			sourceSql.append("count(distinct a.userid, a.type) submit_source_count ");
			sourceSql.append("from loan_order a ");
			sourceSql.append("left join comm_product_channel b on (a.channel = b.channel_code) ");
			sourceSql.append("where 1=1 ");
			sourceSql.append(selectSql);
			sourceSql.append(recordSql);
			sourceSql.append(" group by date, a.channel order by date desc ");
		}
		
		StringBuffer mSql = new StringBuffer();
		
		if (StringUtils.isNotEmpty(api_type)) {
			mSql.append(" and a.api_id = " + api_type);
		}
		if (StringUtils.isNotEmpty(prdId)) {
			mSql.append(" and a.prod_id = '" + prdId + "'");
		}
		if (StringUtils.isNotEmpty(new_activity_type)) {
			mSql.append(" and a.activity_type = '" + new_activity_type + "'");
		}
		if (StringUtils.isNotEmpty(new_activity_Id)) {
			mSql.append(" and a.activity_id = '" + new_activity_Id + "'");
		}
		if (StringUtils.isNotEmpty(startDate)) {
			mSql.append(" and a.create_time >= '" + startDate + " 00:00:00'");
		}
		if (StringUtils.isNotEmpty(endDate)) {
			mSql.append(" and a.create_time <= '" + endDate + " 23:59:59'");
		}

		LogService.info("sourceSql= " + sourceSql.toString());
		
		// 查询API模板API人数
		StringBuffer apiModelReqSql = null;
		
		if (!isChannelResult) {
			apiModelReqSql = new StringBuffer();
			apiModelReqSql.append("select date(a.create_time) date, ");
			apiModelReqSql.append("count(distinct a.user_id) api_count from loan_request_api_model_log a ");
			apiModelReqSql.append("where 1 = 1 ");
			apiModelReqSql.append(selectSql);
			apiModelReqSql.append(mSql);
			apiModelReqSql.append(" group by date ");
			apiModelReqSql.append(" order by date desc ");
		}else{
			apiModelReqSql = new StringBuffer();
			apiModelReqSql.append("select date(a.create_time) date, count(distinct a.user_id) api_count, ");
			apiModelReqSql.append("a.channel, b.channel_name from loan_request_api_model_log a ");
			apiModelReqSql.append("left join comm_product_channel b on (a.channel = b.channel_code) ");
			apiModelReqSql.append("where 1 = 1 ");
			apiModelReqSql.append(selectSql);
			apiModelReqSql.append(mSql);
			apiModelReqSql.append(" group by date, a.channel ");
			apiModelReqSql.append(" order by date desc ");
		}

		LogService.info("apiModelReqSql= " + apiModelReqSql.toString());
		
		// 查询每天API模板投递甲方数
		StringBuffer apiModelInfoSql = null;

		if (!isChannelResult) {
			apiModelInfoSql = new StringBuffer();
			apiModelInfoSql.append("select date(a.create_time) date, ");
			apiModelInfoSql.append("count(distinct a.user_id,a.api_id) api_source_count ");
			apiModelInfoSql.append("from loan_request_api_model_log a where 1=1 ");
			apiModelInfoSql.append(selectSql);
			apiModelInfoSql.append(mSql);
			apiModelInfoSql.append(" group by date order by date desc");
		} else {
			apiModelInfoSql = new StringBuffer();
			apiModelInfoSql.append("select date(a.create_time) date,b.channel_name,");
			apiModelInfoSql.append("a.channel,count(distinct a.user_id,a.api_id) api_source_count ");
			apiModelInfoSql.append("from loan_request_api_model_log a ");
			apiModelInfoSql.append("left join comm_product_channel b on (a.channel = b.channel_code) ");
			apiModelInfoSql.append("where 1=1 ");
			apiModelInfoSql.append(selectSql);
			apiModelInfoSql.append(mSql);
			apiModelInfoSql.append(" group by date,a.channel order by date desc");
		}

		LogService.info("apiModelInfoSql= " + apiModelInfoSql.toString());
			
		
		StringBuffer countSql = null;
		
		if (!isChannelResult) {
			countSql = new StringBuffer();
			countSql.append("select date(ctime) date, count(1) from loan_order a ");
			countSql.append("where 1=1 ");
			countSql.append(selectSql);
			countSql.append(recordSql);
			countSql.append(" group by date");
		}else{
			countSql = new StringBuffer();
			countSql.append("select date(ctime) date, count(1) from loan_order a ");
			countSql.append("where 1=1 ");
			countSql.append(selectSql);
			countSql.append(recordSql);
			countSql.append(" group by date, channel");
		}

		LogService.info("countSql= " + countSql.toString());
		
		List<LoanOrderModel> list = null; // 查询提交API人数
		List<LoanOrderModel> sourceList = null; // 查询每天API投递甲方数
		List<Loan_Request_Api_Model_Log> api_model_list = null; // 查询API模板API人数
		List<Loan_Request_Api_Model_Log> api_model_info_list = null; // 查询每天API模板投递甲方数
		try {
			list = dao.list(sql.toString(), LoanOrderModel.class, new Object[] {});
			sourceList = dao.list(sourceSql.toString(), LoanOrderModel.class, new Object[] {});

			api_model_list = dao.list(apiModelReqSql.toString(), Loan_Request_Api_Model_Log.class, new Object[] {});
			api_model_info_list = dao.list(apiModelInfoSql.toString(), Loan_Request_Api_Model_Log.class, new Object[] {});
					
			List<LoanOrderModel> countList = dao.list(countSql.toString(), LoanOrderModel.class);
            
			if (sourceList != null) {
				for (LoanOrderModel order : list) {
					for (LoanOrderModel model : sourceList) {
						if (!isChannelResult) {
							if (order.getDate().equals(model.getDate())) {
								order.setSubmit_source_count(model.getSubmit_source_count());
							}
						} else {
							if (order.getDate().equals(model.getDate()) && order.getChannel().equals(model.getChannel())) {
								order.setSubmit_source_count(model.getSubmit_source_count());
							}
						}
					}
				}
			}

			if (api_model_list != null) {
				for (LoanOrderModel order : list) {
					for (Loan_Request_Api_Model_Log api_model : api_model_list) {
						if (!isChannelResult) {
							if (order.getDate().equals(api_model.getDate())) {
								order.setApi_count(api_model.getApi_count());
							}
						} else {
							if (order.getDate().equals(api_model.getDate()) && order.getChannel().equals(api_model.getChannel())) {
								order.setApi_count(api_model.getApi_count());
							}
						}
					}
				}
			}
			
			if (api_model_info_list != null) {
				for (LoanOrderModel order : list) {
					for (Loan_Request_Api_Model_Log api_model : api_model_info_list) {
						if (!isChannelResult) {
							if (order.getDate().equals(api_model.getDate())) {
								order.setApi_source_count(api_model.getApi_source_count());
							}
						} else {
							if (order.getDate().equals(api_model.getDate()) && order.getChannel().equals(api_model.getChannel())) {
								order.setApi_source_count(api_model.getApi_source_count());
							}
						}
					}
				}
			}
			
			for (LoanOrderModel order : list) {
				
				if (StringUtils.isEmpty(platform)) {
					order.setPlatform(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(channel) && !isChannelResult) {
					order.setChannel_name(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(environment)) {
					order.setEnvironment(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(request_source)) {
					order.setRequest_source(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(page)) {
					order.setPage(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(ck_module)) {
					order.setCk_module(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(position)) {
					order.setPosition(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(user_type)) {
					order.setUser_type(-1);
				}
				if (StringUtils.isEmpty(order_type)) {
					order.setOrder_type(-1);
				}
				if (StringUtils.isEmpty(api_type)) {
					order.setThird_name(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(prdId)) {
					order.setProduct_name(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(new_activity_type)) {
					order.setNew_activity_type(String.valueOf(-1));
				}
				if (StringUtils.isEmpty(new_activity_Id)) {
					order.setNew_activity_id(String.valueOf(-1));
				}
			}
			pageResponse.setITotalRecords(countList.size());
			pageResponse.setITotalDisplayRecords(countList.size());
		} catch (AppException e) {
			LogService.error(e);
		}
		return list;
	}
	
	@Override
	public String exportStatLoanOrderList(List<LoanOrderModel> list) {

		StringBuffer sf = new StringBuffer();
		sf.append("日期,产品,平台,渠道,推广活动类型,推广活动ID,环境,请求来源,用户类型,页面,模块,位置,合作方,订单类型,请求API资料人数,请求API资料甲方数,提交API人数,提交API甲方数\r\n");

		for (LoanOrderModel vo : list) {
			sf.append("'" + vo.getDate()).append(",");
			sf.append("'" + vo.getProduct_name()).append(",");
			sf.append("'" + vo.getPlatform()).append(",");
			sf.append("'" + vo.getChannel_name()).append(",");
			sf.append("'" + vo.getNew_activity_type()).append(",");
			sf.append("'" + vo.getNew_activity_id()).append(",");
			sf.append("'" + vo.getEnvironment()).append(",");
			String requestSource = vo.getRequest_source();
			if("1".equals(requestSource)) {
				sf.append("'菠萝贷").append(",");
			} else if("2".equals(requestSource)) {
				sf.append("'银河黑卡").append(",");
			} else {
				sf.append("'未知").append(",");
			}
			Integer userType = vo.getUser_type();
			if (userType != null) {
				if (userType == 1) {
					sf.append("老用户").append(",");
				} else if (userType == 2) {
					sf.append("新用户").append(",");
				} else {
					sf.append("--").append(",");
				}
			} else {
				sf.append("--").append(",");
			}
			sf.append("'" + vo.getPage()).append(",");
			sf.append("'" + vo.getCk_module()).append(",");
			sf.append("'" + vo.getProfession()).append(",");
			sf.append("'" + vo.getThird_name()).append(",");

			Integer orderType = vo.getOrder_type();
			if (orderType != null) {
				if (orderType == 1) {
					sf.append("站内").append(",");
				} else if (orderType == 2) {
					sf.append("一键投递API").append(",");
				} else {
					sf.append("--").append(",");
				}
			} else {
				sf.append("--").append(",");
			}
			sf.append(vo.getApi_count()).append(",");
			sf.append(vo.getApi_source_count()).append(",");
			sf.append(vo.getSubmit_count()).append(",");
			sf.append(vo.getSubmit_source_count()).append(",");
			sf.append("\r\n");
		}
		return sf.toString();
	}
}
